Repository navigation
GH Issue 1867: Reject ragged importRows requests and keep values under mixed key casing - #8336
Conversation
…pply DB defaults to omitted columns
…tWithKeys and direct insertRows callers
…ry insert path Replaces the saveRows-only PostgreSQL backfill with a per-row omitted marker honored by the insert statement, so explicit nulls still store NULL.
|
I haven't done the CR yet, but just based on the PR comment: IMHO this is not the expected behavior for import. We should be documenting that import expects "square" data rows. I would like to say the same for insert as well, but that's open for discussion. This statement is a little ambiguous "On every list-of-maps insert path, a column that a row omits gets its database default, including multi-choice columns; an explicit null still stores NULL." Just clarifying that multi-choice columns are always NOT NULL and default to empty array. null/empty conversion should handle this (MultiChoice.Converter) |
OK. I've pushed changes that reject ragged rows, gated by a deprecated feature flag in case someone is relying on the current behavior. |
…of() (#222) ## Rationale This PR removes the deprecated `ListofMapsDataIterator` and moves its remaining callers to `MapDataIterator.of()`, as suggested in review of LabKey/platform#8336. Keeping two ways to build an iterator from a list of maps invites fixes that land in only one of them. ## Related Pull Requests - LabKey/platform#8343 - LabKey/clientModules#155 - LabKey/customModules#294 - LabKey/premiumModules#866 - LabKey/snprcEHRModules#1041 - LabKey/wnprc-modules#1086 ## Changes - `ListofMapsDataIterator` is deleted from platform. - Callers in platform and six module repos now use `MapDataIterator.of()`. The iterator is built on the context of the import that uses it, rather than on a throwaway context.
…of() (#294) ## Rationale This PR removes the deprecated `ListofMapsDataIterator` and moves its remaining callers to `MapDataIterator.of()`, as suggested in review of LabKey/platform#8336. Keeping two ways to build an iterator from a list of maps invites fixes that land in only one of them. ## Related Pull Requests - LabKey/platform#8343 - LabKey/clientModules#155 - LabKey/premiumModules#866 - LabKey/OConnorLabModules#222 - LabKey/snprcEHRModules#1041 - LabKey/wnprc-modules#1086 ## Changes - `ListofMapsDataIterator` is deleted from platform. - Callers in platform and six module repos now use `MapDataIterator.of()`. The iterator is built on the context of the import that uses it, rather than on a throwaway context.
…of() (#1041) ## Rationale This PR removes the deprecated `ListofMapsDataIterator` and moves its remaining callers to `MapDataIterator.of()`, as suggested in review of LabKey/platform#8336. Keeping two ways to build an iterator from a list of maps invites fixes that land in only one of them. ## Related Pull Requests - LabKey/platform#8343 - LabKey/clientModules#155 - LabKey/customModules#294 - LabKey/premiumModules#866 - LabKey/OConnorLabModules#222 - LabKey/wnprc-modules#1086 ## Changes - `ListofMapsDataIterator` is deleted from platform. - Callers in platform and six module repos now use `MapDataIterator.of()`. The iterator is built on the context of the import that uses it, rather than on a throwaway context.
…of() (#1086) ## Rationale This PR removes the deprecated `ListofMapsDataIterator` and moves its remaining callers to `MapDataIterator.of()`, as suggested in review of LabKey/platform#8336. Keeping two ways to build an iterator from a list of maps invites fixes that land in only one of them. ## Related Pull Requests - LabKey/platform#8343 - LabKey/clientModules#155 - LabKey/customModules#294 - LabKey/premiumModules#866 - LabKey/OConnorLabModules#222 - LabKey/snprcEHRModules#1041 ## Changes - `ListofMapsDataIterator` is deleted from platform. - Callers in platform and six module repos now use `MapDataIterator.of()`. The iterator is built on the context of the import that uses it, rather than on a throwaway context.
…of() (#8343) ## Rationale This PR removes the deprecated `ListofMapsDataIterator` and moves its remaining callers to `MapDataIterator.of()`, as suggested in review of #8336. Keeping two ways to build an iterator from a list of maps invites fixes that land in only one of them. ## Related Pull Requests - LabKey/clientModules#155 - LabKey/customModules#294 - LabKey/premiumModules#866 - LabKey/OConnorLabModules#222 - LabKey/snprcEHRModules#1041 - LabKey/wnprc-modules#1086 ## Changes - `ListofMapsDataIterator` is deleted from platform. - Callers in platform and six module repos now use `MapDataIterator.of()`. The iterator is built on the context of the import that uses it, rather than on a throwaway context. ## Tasks - [x] Claude Code Review - [x] Manual Testing - N/A - [x] Test Automation - N/A
…1_fb_di_importrows_first_row_cols_1867
| f = new RowMapFactory<>(); | ||
| CaseInsensitiveHashMap<Object> referenceCasing = new CaseInsensitiveHashMap<>(); | ||
| // GH Issue 1867: row maps share casing state, so a later row's spelling of a key would hide earlier rows' values | ||
| CaseInsensitiveHashMap<String> keySpellings = new CaseInsensitiveHashMap<>(); |
There was a problem hiding this comment.
Manual testing: Bug. The square-rows check runs before addRowAttachments. @labkey/api's bindSaveRowsCommand deletes File values from each row and sends them as separate multipart parts. So in a list with an attachment field, if row 0 has a File and row 1 sends Attachment: null, the server sees row 0 without the key and row 1 with it. The request gets rejected even though the user sent the same fields in every row.
I wrote up a regression test and it was able to reproduce this problem. Attached is a patch with the test and a suggested fix. Feel free to revise and/or move the test to a different test since it sits in a different repo.
There was a problem hiding this comment.
I moved the test into ImportRowsTestCase to keep this in one PR. A little clunky in terms of the multipart submission but I confirmed it fails without the fix and passes with it.
Rationale
This PR stops saveRows commands from silently losing data when rows in one request differ in which fields they supply or how they spell a field name (GH Issue 1867). importRows built its columns from the first row, so fields that only later rows supplied were dropped, and on any command a later row spelling a key in different case blanked that field in earlier rows, all while the request reported success.
Behavior change for reviewers: an importRows request whose rows don't all supply the same fields now fails, naming the first mismatched row and its missing and unexpected fields. The new deprecated feature "Allow importRows rows with differing fields" accepts such requests again, storing NULL for any field a row omits. Insert, update, and delete still accept rows with differing fields.
Changes